package com.ogilvy.cms.dao.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.ogilvy.cms.bean.CmsRole;
import com.ogilvy.cms.dao.CmsRoleDao;
import com.ogilvy.frame.util.CmsUtils;

@Repository
public class CmsRoleDaoImpl extends CmsBaseDaoImpl<CmsRole> implements CmsRoleDao{
	public List<CmsRole> getListByScreen(Map<String,String> screenMap) {
		StringBuffer hql=new StringBuffer();
		hql.append("from com.ogilvy.cms.bean.CmsRole cr where ");
		 hql.append(" cr.cmroName like '%"+CmsUtils.SqlReplace(screenMap.get("cmroName"))+"%'");
		 hql.append(" and cr.cmroDesc like '%"+CmsUtils.SqlReplace(screenMap.get("cmroDesc"))+"%'");
		 hql.append(" and cr.cmroAdduser like '%"+CmsUtils.SqlReplace(screenMap.get("cmroAdduser"))+"%'");
		/* if(!"".equals(screenMap.get("startTime")))
		 hql.append(" and  CONVERT(varchar(100), cr.cmroAddtime, 23)>=convert(date,'"+screenMap.get("startTime")+"')");
		 if(!"".equals(screenMap.get("endTime")))
		 hql.append(" and  CONVERT(varchar(100), cr.cmroAddtime, 23)<=convert(date,'"+screenMap.get("endTime")+"')");*/
		// 建立查询语句
		Query query = getSession().createQuery(hql.toString());
		List<CmsRole>  list = query.list();
		if (list == null) {
			list = new ArrayList<CmsRole>();
		}
		return list;
	}
}
